package model

import (
	"database/sql"

	"torler.com/qingyue/common/types"
)

type BookInfo struct {
	Id             types.TableId    `gorm:"column:id;primaryKey;autoIncrement"`                      //自增ID,主键,自动递增,创建时忽略
	BookName       string           `gorm:"column:book_name;type:varchar(50);uniqueIndex:idx_bi_ba"` //小说名
	Author         string           `gorm:"column:author;type:varchar(20);uniqueIndex:idx_bi_ba"`    //作者
	CategoryName   string           `gorm:"column:category_name;type:varchar(20)"`                   //小说分类
	Desc           string           `gorm:"column:desc;type:text"`                                   //小说简介
	ChapterCount   int              `gorm:"column:chapter_count;type:int;default:0"`                 //已经存在的章节数量
	WriteState     types.WriteState `gorm:"column:write_state;type:tinyint(1);default:0"`            //写作状态
	ImgUrl         string           `gorm:"column:img_url;type:varchar(255)"`                        //封面
	LastUpdateTime sql.NullTime     `gorm:"column:last_utime;type:datetime(0)"`                      //源站最近更新时间
	State          types.BookState  `gorm:"column:state;type:tinyint(1);default:0"`                  //上架状态
	types.Basic
}

func NewBookInfo(bookName, author string) *BookInfo {
	return &BookInfo{
		BookName: bookName,
		Author:   author,
	}
}
func (BookInfo) TableName() string {
	return "sp_book"
}
